package com.askinhand.action;

import javax.annotation.Resource;

import org.apache.struts2.json.annotations.JSON;

import com.askinhand.bean.User;
import com.askinhand.bean.UserInfo;
import com.askinhand.service.IUserService;
import com.opensymphony.xwork2.ActionSupport;

public class UserInfoSaveAction extends ActionSupport {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	IUserService userService;
	UserInfo userinfo;
	String uid;

	int age;
	String email;
	String gender;
	String name;
	String phone;
	String skilled;

	String strResult;

	@JSON(serialize = false)
	public IUserService getUserService() {
		return userService;
	}

	@Resource
	public void setUserService(IUserService userService) {
		this.userService = userService;
	}

	@JSON(serialize = false)
	public UserInfo getUserinfo() {
		return userinfo;
	}

	public void setUserinfo(UserInfo userinfo) {
		this.userinfo = userinfo;
	}

	@JSON(serialize = false)
	public String getUid() {
		return uid;
	}

	public void setUid(String uid) {
		this.uid = uid;
	}

	@JSON(serialize = false)
	public int getAge() {
		return age;
	}

	public void setAge(int age) {
		this.age = age;
	}

	@JSON(serialize = false)
	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	@JSON(serialize = false)
	public String getGender() {
		return gender;
	}

	public void setGender(String gender) {
		this.gender = gender;
	}

	@JSON(serialize = false)
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@JSON(serialize = false)
	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	@JSON(serialize = false)
	public String getSkilled() {
		return skilled;
	}

	public void setSkilled(String skilled) {
		this.skilled = skilled;
	}

	public String getStrResult() {
		return strResult;
	}

	public void setStrResult(String strResult) {
		this.strResult = strResult;
	}

	public String execute() {

		UserInfo userinfo = new UserInfo();
		System.out.println(uid);
		userinfo.setAge(age);
		userinfo.setEmail(email);
		userinfo.setGender(gender);
		userinfo.setName(name);
		userinfo.setPhone(phone);
		userinfo.setSkilled(skilled);
		
		User user = new User();
		user.setId(Integer.parseInt(uid));
		userinfo.setUser(user);

		strResult = userService.userInfoSave(userinfo);
		System.out.println(userinfo.getName());
		return "success";
	}
}
